﻿using EntityframeworkHelper.Data.EntityExtend;
using System.Threading.Tasks;

namespace EntityFrameworkHelper.UnitOfWorks
{
    /// <summary>
    ///     Interface IUnitOfWork
    /// </summary>
    public interface IUnitOfWork<TKey, out TContext>
    {
        /// <summary>
        ///     Initializes the context.
        /// </summary>
        /// <returns>TContext.</returns>
        TContext Create();

        /// <summary>
        ///     Repositories this instance.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns>IRepository&lt;T&gt;.</returns>
        IRepository<T> Repository<T>() where T : EntityBase<TKey>;

        /// <summary>
        ///     Saves the changes.
        /// </summary>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        bool SaveChanges();

        /// <summary>
        ///     Saves the changes.
        /// </summary>
        /// <returns>Task.</returns>
        Task<bool> SaveChangesAsync();
    }
}